import { Component, OnInit, AfterViewInit  } from '@angular/core';
import { GlobalService } from './global/global.service';
import { setUserOpinidAndToken } from './util/userInfo';

@Component({
	selector: 'app-root',
	templateUrl: './app.component.html',
	styleUrls: ['./app.component.less']
})
export class AppComponent implements OnInit, AfterViewInit  {
	title = 'BothHelpPlatfrom';
	showMessage = true;
	messageText = '';
	clickIcon = {
		publicActive: false,
		taskActive: true,
		selfActive: false
	};
	constructor(private globalService: GlobalService) {	}

	ngOnInit(): void {
		// 从跳转中拿取openId
		setUserOpinidAndToken('o8n3iw-dh4aqz091W7SpVd-i7LkY', '');
	}
	ngAfterViewInit(): void {
		this.globalService.getMessageText().subscribe((value) => {
			setTimeout(() => {
				this.showMessage = value.isShowMessage;
				this.messageText = value.text;
			});
		});
	}
	changeIconName(type: string) {
		Object.keys(this.clickIcon).forEach((key) => {
			this.clickIcon[`${key}`] = false;
		});
		this.clickIcon[`${type}`] = !this.clickIcon[`${type}`];
	}
}
